package com.copa.l2011;

/**
 * @author copa
 * @createDate 2022-12-23 11:11
 * @function 常规法
 */
public class Test1 {

    public int finalValueAfterOperations(String[] operations) {
        int result = 0;
        for (String operation : operations) {
            result += getValue(operation);
        }
        return result;
    }

    private Integer getValue(String operation) {
        if ("X--".equals(operation) || "--X".equals(operation)) {
            return -1;
        }
        return 1;
    }

    public static void main(String[] args) {
        String[] operations = new String[]{"X++","++X","--X","X--"};
        System.out.println(new Test1().finalValueAfterOperations(operations));
    }
}
